﻿@page
@using Volo.Abp.Account.Settings
@using Volo.Abp.Settings
@using Microsoft.Extensions.Localization
@using Microsoft.Extensions.Options
@using Volo.Abp.AspNetCore.Mvc.AntiForgery
@using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy.Localization
@using Volo.Abp.AspNetCore.MultiTenancy
@using Volo.Abp.MultiTenancy
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components
@using Coso.Abp.Theme.AdminLTE.Themes.AdminLTE.Components.PageAlerts
@using Coso.Abp.Theme.AdminLTE.Themes.AdminLTE.Components.Toolbar.LanguageSwitch
@using Volo.Abp.Account.Localization
@using Microsoft.AspNetCore.Mvc.Localization

@model Volo.Abp.Account.Web.Pages.Account.RegisterModel
@inject IHtmlLocalizer<AccountResource> L
@inject Volo.Abp.Settings.ISettingProvider SettingProvider
@inject IAbpAntiForgeryManager AbpAntiForgeryManager
@inject IOptions<AbpMultiTenancyOptions> MultiTenancyOptions
@inject ICurrentTenant CurrentTenant
@inject IStringLocalizer<AbpUiMultiTenancyResource> MultiTenancyStringLocalizer
@inject ITenantResolveResultAccessor TenantResolveResultAccessor
@inject IBrandingProvider BrandingProvider

<abp-row>
    <abp-column class="login">
        <div class="account-brand p-3 text-center mb-1">
            <a routerlink="/" alt="MyProjectName" class="navbar-brand" href="/">

                <img src="@(string.IsNullOrWhiteSpace(BrandingProvider.LogoReverseUrl) ? "/themes/adminlte/img/AdminLTELogo.png" : BrandingProvider.LogoReverseUrl)"
                     alt="AdminLTE Logo" class="brand-image img-circle elevation-3"
                     style="opacity: .8;height:50px;">
            </a>
        </div>
        <div class="card">

            <div class="card-header">
                <h2 class="card-title d-inline-block">@L["Register"]</h2>
                <nav class="navbar navbar-expand p-0 pt-1 float-right">
                    <ul class="navbar-nav ml-auto toolbar-nav">
                        @(await Component.InvokeAsync<LanguageSwitchViewLoginComponent>())
                    </ul>
                </nav>
            </div>

            <div class="card-header bg-light ">
                <div class="tenant-switch-box">
                    <div class="row">
                        <div class="col pr-1">
                            <h6 class="m0"> @MultiTenancyStringLocalizer["Tenant"] </h6>
                            @if (CurrentTenant.Id == null)
                            {
                                <i>
                                    @MultiTenancyStringLocalizer["NotSelected"]
                                </i>
                            }
                            else
                            {
                                <strong>@(CurrentTenant.Name ?? CurrentTenant.Id.Value.ToString())</strong>
                            }
                        </div>
                        <div class="col-auto pl-1">
                            @if (MultiTenancyOptions.Value.IsEnabled &&
(TenantResolveResultAccessor.Result?.AppliedResolvers?.Contains(CookieTenantResolveContributor.ContributorName) == true))
                            {
                                <a id="AbpTenantSwitchLink" href="javascript:;" class="btn btn-sm mt-3 btn-outline-primary">@MultiTenancyStringLocalizer["Switch"]</a>
                            }
                        </div>
                    </div>
                </div>
            </div>

            <div class="card-body">
                <form method="post" class="mb-3">
                    <abp-input asp-for="Input.UserName" auto-focus="true" />
                    <abp-input asp-for="Input.EmailAddress" />
                    <abp-input asp-for="Input.Password" />
                    <abp-button button-type="Primary" type="submit" class="btn-lg btn-block mt-4">@L["Register"]</abp-button>
                </form>

                <strong>
                    @L["AlreadyRegistered"]
                    <a href="@Url.Page("./Login", new {returnUrl = Model.ReturnUrl, returnUrlHash = Model.ReturnUrlHash})" class="text-decoration-none">@L["Login"]</a>
                </strong>


            </div>
        </div>
        @(await Component.InvokeAsync<PageAlertsViewComponent>())

    </abp-column>
</abp-row>